package com.qf.advice;

/**
 * @author 孙亚梅
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.advice
 * @Description:
 * @Date 2022/6/6 16:44
 */

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * 环绕通知：
 *          先执行环绕通知：例如开启事务
 *          再执行核心service中的增删改查方法
 *          再执行环绕通知：例如提交事务
 */
public class MyAroundAdvice implements MethodInterceptor {
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("======环绕通知：开启事务MethodInterceptor==============");
        Object proceed = methodInvocation.proceed();//调用执行核心service中的业务方法
        System.out.println("========环绕通知：提交事务MethodInterceptor===============");
        return proceed;
    }
}
